package com.job.redbook;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author angzhijin
 * @Description
 * @create 2022-09-04 3:48 PM
 */
public class RedBook0904 {
    public static void main(String[] args) {
//        a(args);

        b(args);
    }


    public static void a(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();
        int[] nums =new int[n*2];
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
            nums[2*n-i-1] = nums[i];
        }
        while(k > 2*n){
            k -= 2*n;
        }
        if(k<=n)
            System.out.println(nums[k-1]);
        else
            System.out.println(nums[2*n-k]);
    }


    public static void b(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] nums = new int[n];
        int sum = 0;
        int flag= 0; // 离7 还是-7近
        int flagIndex = -1;  // 最近的那个下标
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();

        }


    }


    public static void c(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();
        int[][] cost = new int[n+1][n+1];
        for (int i = 0; i <= n; i++) {
            Arrays.fill(cost[i], Integer.MAX_VALUE);
        }
        int[] start = new int[m];
        for (int i = 0; i < m; i++) {
            start[i] = sc.nextInt();
        }
        int[] end = new int[m];
        for (int i = 0; i < m; i++) {
            end[i] = sc.nextInt();
        }
        for (int i = 0; i < m; i++) {
            cost[start[i]][end[i]] = sc.nextInt();
        }
        int res = min(cost, n);
        System.out.println(res);
    }

    public static int min(int[][] cost, int n){
        int[][] dp = new int[n][n];
        for (int i = 1; i < n ; i++) {
            for (int j = 1; j < n; j++) {
                if(i==1 && j==1){
                    dp[i][j] = cost[0][0];
                }else if(i==1){
                    dp[i][j] = Math.min(cost[i][j], dp[i][j-1]);
                }else if(j==1){
                    dp[i][j] = Math.min(cost[i][j],dp[i-1][j]);
                }else{
                    dp[i][j] = Math.min(cost[i][j],  Math.min(dp[i][j-1], dp[i-1][j]));
                }
            }
        }
        return dp[n-1][n-1];
    }
}
